//---------------------------------------------------------------------------- // File: C3DRenderBank.h // Version: 3.0 // Class: C3DRenderBank // Type: 3D Bank Manager // Author: Ken Anderson // Date: 2/1/06 // Updates: // 9/13/04 -- The DeallocateSlot member function was fixed as it previously had // been attempting to pass the renderbank callback as the a cbank callback; // however, these are two different structures causing memory leaks & access // violation errors. // // Version 2.0 -- System updated to manage the HRBE callback only due to the complexities of // the individual handles provided by the special buffer & object. // // Version 3.0 -- [2/1/6]System updated to reflect another hrbe embedded within. // // OS dependant: NA // Desc: Contains a specialized bank that uses the CBank structure as a private // member variable, to manage and control the bank of void data structures. // The class was designed to act as a protection manager, not allowing // the bank to be destroyed without cleaning up the specialized void // handles that were used. // // Notes: NOT DERVIVED FROM CBANK // Error codes can be reviewed in CBank.h // // Required headers: // 1) Common.h -- Contains common structures, definitions, type definitions // and other features not dependant on any operating // system or system. // //---------------------------------------------------------------------------- //Prevent redefinition #ifndef __C3DRenderBank__ #define __C3DRenderBank__ #include "Common.h" #define BKERR_SLOTREMOVALHALTED (BK_COUNT + 0) //The slot removal process was halted. ///////////////////////////// // DEFINITIONS // ///////////////////////////// typedef enum RENDER_BANK_STATES { BSV_NS = 0x00, //No state. BSV_NEW = 0x01, //Object is new and requires a specialized rendering buffer. BSV_UPDATE = 0x02, //Object requres a new render buffer and the old one to be destroyed. BSV_RENDER = 0x04, //Object is safe for rendering. BSV_REFRESH = 0x08, //Safe to render, but requires updating. BSV_DESTROY = 0x10, //Object needs to be destroyed. } C3DRenderBankStates; ///////////////////////////// // TYPE DEFS // ///////////////////////////// typedef struct RENDER_BANK_ELEMENT { C3DRenderBankStates rbsState; //Render bank states. void* pSpecialBuffer; //Special buffer used by renderer. void* p3DObject; //Object that called the bank and requested a slot. void* pNext; //Allows for a secondary RBE link. } RBE, *PRBE, **HRBE, ***TRBE; class C3DRenderBank { //Class member variables private: CBank* m_pbank; //Class member functions public: //Constructors & Destructors C3DRenderBank(); ~C3DRenderBank(); BANKERR Create(); inline void Destroy(){Cleanup();} //Common 3d object management. //The following members should be called by the common 3d object management. //Object updating features for common 3d objects to manage. BANKERR AllocateSlot(HRBE* tCallback); //Allocate a slot in the bank. BANKERR DeallocateSlot(HRBE* tCallback); //Tell the bank to clean up current slot. BANKERR RetrieveCallback(BST bstIndex, HRBE* tCallback); //Returns the callback based on the index. inline BST Depth(){return (m_pbank != NULL)?m_pbank->Depth():0;} //Returns the depth of the bank. BANKERR UpdateBuffer(HRBE hCallback); //Inform the bank to update the current slot & rebuild buffer. BANKERR RefreshSlot(HRBE hCallback); //Inform the bank to refresh or update the current slot. private: void Cleanup(); //Clean up the render bank. }; #endif